import storejs from '@/utils/storejs';
import API from '@/api/index.js';

const keys = {
	currentShop: 'currentShop',
	currentShopUid: 'currentShopUid',
};

// 管理后台状态
const state = {
	// 当前管理的店铺uid
	currentShopUid: storejs.get(keys.currentShopUid),
	currentShop: storejs.get(keys.currentShop),
}


const getters = {

}

const mutations = {
	/**
	 * 设置当前管理的店铺
	 * @param {Object} state
	 * @param {Object} shopInfo
	 */
    setCurrentShop(state, shopInfo){
        let shopUid = shopInfo.uid;
		if (!state.currentShop) {
			state.currentShop = shopInfo;
			state.currentShopUid = shopUid;
			
			// 保存到本地
			storejs.set(keys.currentShop, shopInfo);
			storejs.set(keys.currentShopUid, shopUid);
		}
    },
}

const actions = {
    
};


export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
}
